package com.liao.healthydiet.ui.activity;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager.widget.ViewPager;

import com.liao.healthydiet.R;
import com.liao.healthydiet.ui.adapter.GuideViewPagerAdapter;

import java.util.ArrayList;

public class GuideActivity extends AppCompatActivity implements View.OnClickListener {

    private ViewPager viewPager;
    private GuideViewPagerAdapter adapter;
    private ArrayList<View> views;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_guilde);
        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.hide();
        }
        initView();
    }

    @SuppressLint("InflateParams")
    private void initView() {
        viewPager = (ViewPager) findViewById(R.id.viewPager);
        View view1 = getLayoutInflater().inflate(R.layout.viewpager_giude1_layout, null);
        View view2 = getLayoutInflater().inflate(R.layout.viewpager_giude2_layout, null);
        View view3 = getLayoutInflater().inflate(R.layout.viewpager_giude3_layout, null);
        views = new ArrayList<>();
        views.add(view1);
        views.add(view2);
        views.add(view3);
        view3.findViewById(R.id.btn_into).setOnClickListener(this);
        adapter = new GuideViewPagerAdapter(views);
        viewPager.setAdapter(adapter);
    }

    @Override
    public void onClick(View v) {
        startActivity(new Intent(this, MainActivity.class));
        finish();
    }
}
